/*
 * Copyright (C) 2011-2012 5ifilm.net. All Rights Reserved.
 *
 * $Id: SlideFilmDao.java 2012-08-05 WangJun$
 *
 */
package net.ifilm.dao;

import com.ibatis.sqlmap.client.SqlMapClient;
import net.ifilm.entity.FilmScore;
import net.ifilm.entity.SlideFilm;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 幻灯电影表<tt>slidefilm</tt>数据库操作类。
 * 
 * User: <a href="wangjunneil@gmail.com">wangjun</a> Date: 2012-08-05 23:09
 */
@Repository
public class FilmScoreDao extends BaseDao {

    /**
     * 根据电影ID删除电影评分纪录
     *
     * @param filmId
     */
    public boolean deleteSocre(int filmId) {
        int updateCount = (Integer)super.delete("delScoreById", filmId);
        return updateCount != 0;
    }

    /**
     * 添加电影评分
     *
     * @param filmScore
     * @return
     */
    public void insertFilmSocre(FilmScore filmScore) {
//        int updateCount = (Integer)super.insert("insertFilmSocre", filmScore);
//        return updateCount != 0;
        super.insert("insertFilmSocre", filmScore);

    }

    /**
     * 查询电影平均分
     *
     * @param filmId
     * @return
     */
    public double queryAvgScore(int filmId) {
        Object score = super.queryForObject("queryAvgScore", filmId);
        if (score == null) return 0.0;
        return (Double)score;
    }

    /**
     * 查询电影评分基数
     *
     * @param filmId
     * @return
     */
    public int queryScoreCount(int filmId) {
        return (Integer)super.queryForObject("queryScoreCount", filmId);
    }
    
} // /:~
